<?php

namespace aerovuelos\UsuarioBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;


class UsuariosType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('usuario')
            ->add('password', 'repeated', array(
                    'type' => 'password',
                    'invalid_message' => 'Las dos contraseñas deben coincidir',
                    'first_options' => array('label' => 'Password', 'attr' => array('class' => 'text')),
                    'second_options' => array('label' => 'Re-Password', 'attr' => array('class' => 'text'))
                ))
            ->add('tipoUsuarios', null, array(
                    'required' => true,
                    'attr' => array('class' => 'uniform')
                ))
        ;
        $builder->add('personas', new \aerovuelos\PersonaBundle\Form\PersonasType());
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'aerovuelos\UsuarioBundle\Entity\Usuarios',
            'cascade_validation' => true,
        ));
    }

    public function getName()
    {
        return 'aerovuelos_usuariobundle_usuariostype';
    }
}
